home *** CD-ROM | disk | FTP | other *** search
- import java.util.Vector;
- import javax.microedition.rms.RecordComparator;
- import javax.microedition.rms.RecordEnumeration;
- import javax.microedition.rms.RecordFilter;
- import javax.microedition.rms.RecordStore;
-
- class Database {
- // $FF: renamed from: rs javax.microedition.rms.RecordStore
- protected RecordStore field_0;
- protected Vector ids = new Vector();
-
- Database(String var1) {
- try {
- this.field_0 = RecordStore.openRecordStore(var1, true);
- RecordEnumeration var2 = this.field_0.enumerateRecords((RecordFilter)null, (RecordComparator)null, false);
-
- while(var2.hasPreviousElement()) {
- this.ids.addElement(new Integer(var2.previousRecordId()));
- }
-
- var2.destroy();
- } catch (Exception var3) {
- }
-
- }
-
- void close() {
- try {
- this.field_0.closeRecordStore();
- } catch (Exception var2) {
- }
-
- }
-
- int getIndex(int var1) {
- return this.ids.indexOf(new Integer(var1));
- }
-
- int getId(int var1) {
- return (Integer)this.ids.elementAt(var1);
- }
-
- int numRecords() {
- return this.ids.size();
- }
-
- byte[] getRecord(int var1) {
- try {
- return this.field_0.getRecord(var1);
- } catch (Exception var3) {
- return null;
- }
- }
-
- boolean addRecord(byte[] var1) {
- try {
- this.ids.addElement(new Integer(this.field_0.addRecord(var1, 0, var1.length)));
- return true;
- } catch (Exception var3) {
- return false;
- }
- }
-
- boolean setRecord(int var1, byte[] var2) {
- try {
- this.field_0.setRecord(var1, var2, 0, var2.length);
- return true;
- } catch (Exception var4) {
- return false;
- }
- }
-
- boolean deleteRecord(int var1) {
- try {
- this.field_0.deleteRecord(var1);
- this.ids.removeElementAt(this.getIndex(var1));
- return true;
- } catch (Exception var3) {
- return false;
- }
- }
- }
-